package com.requiem.hist_group_manage_springboot.controller;

import com.requiem.hist_group_manage_springboot.common.TimeParserUtil;
import com.requiem.hist_group_manage_springboot.exception.R;
import com.requiem.hist_group_manage_springboot.mapper.DataMapper;
import com.requiem.hist_group_manage_springboot.model.DataModel;
import com.requiem.hist_group_manage_springboot.service.DataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/data")
public class DataController {

    @Autowired
    DataMapper dataMapper;
    @Autowired
    TimeParserUtil timeParserUtil;
    @Autowired
    DataService dataService;

    @GetMapping("/getList")
    R getList() {
        List<DataModel> list = dataMapper.getList();
        return R.success(list);
    }

    @GetMapping("/getByID")
    R getByID(@RequestParam String department) {
        List<DataModel> list = dataMapper.getByID(department);
        return R.success(list);
    }

    @GetMapping("/getData")
    R getData() {
        return dataService.getData();
    }
}
